#pragma once

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "..\Gears\CdiObject.h"


class CdiWindow 
  : public CdiObject
{
  // Private Member Variables
  ////////////////////////////////
  LPCWSTR     m_title; 
  WNDCLASSEX  m_wndClassEx;

protected:
  // Protected Member Variables
  ////////////////////////////////

  // Handle to the Window
  ////////////////////////////////
  HWND        m_hWnd;

  // Handle to the Parent Window
  ////////////////////////////////
  HWND        m_hWndParent;

  // The window is setup
  ////////////////////////////////
  bool        m_isInit;

  // Width
  /////////////////////////////////
  int         m_screenWidth;

  // Height
  /////////////////////////////////  
  int         m_screenHeight;

  // Screen Middle Width
  /////////////////////////////////
  int         m_screenWidthMiddle;

  // Screen Middle Width
  /////////////////////////////////
  int         m_screenHeightMiddle;

public:

  // Constructors & Dtors
  ////////////////////////////////
  CdiWindow( WNDPROC wndProc, LPCWSTR Title);

  CdiWindow( WNDPROC wndProc, LPCWSTR Title, int screenWidth, int screenHeight );

  virtual ~CdiWindow();

protected:
  // Setup
  ////////////////////////////////
  virtual void Setup( WNDPROC wndProc );

  void ReadConfig() { }

  // Sets the mouse position to the center of the active window
  void CenterMousePosition(void);

public:
  // Methods
  ////////////////////////////////

  // Start the window message pump
  ////////////////////////////////
  virtual void Start();

  // IsInit
  ////////////////////////////////
  inline bool IsInit() const { return m_isInit; }

  // GetHWND
  ////////////////////////////////
  inline HWND GetHWND() const { return (const HWND)m_hWnd; }

  // Set the window Title
  void SetTitle( LPCWSTR Title );

  // Determine wheter this window has focus
  inline bool HasFocus(void);
  
  // Set the Parent window
  void SetParent( HWND Parent ) { m_hWndParent = Parent; }
  HWND GetParent() const { return m_hWndParent; }

  virtual void AssertValid();
};
